IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[fncGetCodeName]') 
											AND type in (N'FN', N'IF', N'TF', N'FS', N'FT'))
DROP FUNCTION [dbo].[fncGetCodeName]

GO


CREATE Function [dbo].[fncGetCodeName]
(
    @CD_SYU char(5),
    @CD varchar(8)
)
RETURNS varchar(50)
AS
BEGIN
	RETURN (
SELECT CD_NM as CodeName from M_CD WHERE CD_SYU = @CD_SYU AND CD_KB = '2' AND CD=@CD
)
END


